﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QuTouTiaoAssist.Entity;
using QuTouTiaoAssist.Util;

namespace QuTouTiaoAssist
{
    class GlobalContext
    {
        /// <summary>
        /// 当前MemberToken
        /// </summary>
        public static string MemberToken;

        /// <summary>
        /// 当前MemberInfo
        /// </summary>
        public static QttMemberInfo MemberInfo;

        /// <summary>
        /// 检测是否已经登录
        /// </summary>
        /// <returns></returns>
        public static bool CheckLogin(bool isShowTip)
        {
            if (OtherUtil.IsNullOrWhitespace(MemberToken) || MemberInfo == null)
            {
                if (isShowTip)
                {
                    MsgBox.ShowInfo("请先登录！");
                }
                return false;
            }
            return true;
        }

        public static Form MainForm = null;

        public static void ChangeMainTitle(string str)
        {
            if (MainForm != null)
            {
                if (MainForm.InvokeRequired)
                {
                    MainForm.Invoke(new Action<string>(ChangeMainTitle), str);
                    return;
                }
                else
                {
                    MainForm.Text = str;
                }
            }
        }

        /// <summary>
        /// 新注册用户手机号密码缓存
        /// </summary>
        public static Dictionary<string, string> NewRegisterMobilePwdCache = new Dictionary<string, string>(); 
    }
}
